<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./index.vue">
    <style scoped lang="less">
        .form-preview {
          position: relative;
          display: flex;
          align-items: center;
        }
        .form-preview h2 {
          font-size: 18px;
          font-weight: normal;
        }
        .form-preview small {
          font-size: 12px;
          display: inline-block;
          padding: 2px 6px;
          background: #27ba9b;
          color: #fff;
          border-radius: 2px;
          transform: scale(0.8);
        }
        .form-preview .btn-edit {
          font-size: 12px;
          display: none;
          text-decoration: none;
          color: #069;
          margin-left: 20px;
        }
        .form-preview:hover .btn-edit {
          display: block;
        }
        .form-edit {
          padding-top: 20px;
        }
        .form-item {
          display: flex;
          margin-bottom: 20px;
          align-items: center;
        }
        .form-item .label {
          width: 60px;
          text-align: right;
          font-size: 14px;
        }
        .form-item .input {
          flex: 1;
        }
        .form-item input,
        .form-item select {
          appearance: none;
          outline: none;
          border: 1px solid #ccc;
          width: 200px;
          height: 40px;
          box-sizing: border-box;
          padding: 10px;
          color: #666;
        }
        .form-item input::placeholder {
          color: #666;
        }
        .form-item .cancel,
        .form-item .submit {
          appearance: none;
          outline: none;
          border: 1px solid #ccc;
          border-radius: 4px;
          padding: 4px 10px;
          margin-right: 10px;
          font-size: 12px;
          background: #ccc;
        }
        .form-item .submit {
          border-color: #069;
          background: #069;
          color: #fff;
        }
        </style>
    
</head>
<body>
    <div class="article-case">
        <div class="form-preview">
          <h2>文章标题</h2>
          <small>文章频道</small>
          <a class="btn-edit" href="#" @click="show(i)">编辑</a>
        </div>
        <div class="form-edit" v-show="isshow">
          <div class="form-item">
            <div class="label">标题：</div>
            <div class="input">
              <input type="text" placeholder="请输入标题" v-model='msg.title' />
            </div>
          </div>
          <div class="form-item">
            <div class="label">频道：</div>
            <div class="input">
              <select v-model="msg.jishu">
                <option value="">请选择频道</option>
                <option value="前端">前端</option>
                <option value="运维">运维</option>
                <option value="测试">测试</option>
              </select>
            </div>
          </div>
          <div class="form-item">
            <div class="label"></div>
            <div class="input">
              <button class="cancel" @click="quXiao()">取消</button>
              <button class="submit" @click="quRen()">确认</button>
            </div>
          </div>
        </div>
      </div>

    <script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
    <script>
      new Vue({
        el:'.article-case',
        data:{
          i :0,
          isshow:false,
          msg:{
            title:'',
            jishu:''

          }
        },
        methods: {
          show(i){
        
           if(this.i =1){
            this.i +=1
            this.isshow = true

           }
           this.i = 0

          },
          quRen(){
            if(this.msg.title ===''||this.msg.jishu==='') return alert('请输入标题或者频道')
            alert('输入成功')
             this.isshow = false
          },
          quXiao(){
          if(this.msg.title ===''||this.msg.jishu===''){
            if(confirm('你确定要取消吗,内容是空的哟?')){
              this.isshow = false
            }
          }else if(confirm('你确定取消吗?')){
            this.isshow = false
          }
          }

      
      }})
    </script>
   
   
    
    
</body>
</html>